package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.CzAircraft;
import com.ruoyi.business.service.ICzAircraftService;
import com.ruoyi.common.utils.poi.ExcelUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 航空器登记Controller
 * 
 * @author ruoyi
 * @date 2022-01-09
 */
@Api(tags = "航空器登记")
@RestController
@RequestMapping("/business/aircraft")
public class CzAircraftController extends BaseController
{
    @Autowired
    private ICzAircraftService czAircraftService;

    /**
     * 查询航空器登记列表
     */
    @ApiOperation(value = "查询航空器登记列表")
    @PreAuthorize("@ss.hasPermi('business:aircraft:list')")
    @GetMapping("/list")
    public TableDataInfo list(CzAircraft czAircraft)
    {
        startPage();
        List<CzAircraft> list = czAircraftService.selectCzAircraftList(czAircraft);
        return getDataTable(list);
    }

    /**
     * 导出航空器登记列表
     */
    @ApiOperation(value = "导出航空器登记列表")
    @PreAuthorize("@ss.hasPermi('business:aircraft:export')")
    @Log(title = "航空器登记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CzAircraft czAircraft)
    {
        List<CzAircraft> list = czAircraftService.selectCzAircraftList(czAircraft);
        ExcelUtil<CzAircraft> util = new ExcelUtil<CzAircraft>(CzAircraft.class);
        util.exportExcel(response, list, "航空器登记数据");
    }

    /**
     * 获取航空器登记详细信息
     */
    @ApiOperation(value = "获取航空器登记详细信息")
    @PreAuthorize("@ss.hasPermi('business:aircraft:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(czAircraftService.selectCzAircraftById(id));
    }

    /**
     * 新增航空器登记
     */
    @ApiOperation(value = "新增航空器登记")
    @PreAuthorize("@ss.hasPermi('business:aircraft:add')")
    @Log(title = "航空器登记", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CzAircraft czAircraft)
    {
        return toAjax(czAircraftService.insertCzAircraft(czAircraft));
    }

    /**
     * 修改航空器登记
     */
    @ApiOperation(value = "修改航空器登记")
    @PreAuthorize("@ss.hasPermi('business:aircraft:edit')")
    @Log(title = "航空器登记", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CzAircraft czAircraft)
    {
        return toAjax(czAircraftService.updateCzAircraft(czAircraft));
    }

    /**
     * 删除航空器登记
     */
    @ApiOperation(value = "删除航空器登记")
    @PreAuthorize("@ss.hasPermi('business:aircraft:remove')")
    @Log(title = "航空器登记", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(czAircraftService.deleteCzAircraftByIds(ids));
    }
}
